<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>北京联合大学</title>
</head>
<!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link rel="stylesheet" href="https://at.alicdn.com/t/font_835526_jvf25y11i0p.css">
<link rel="stylesheet" href="../../css/Initialization.css">
<link rel="stylesheet" href="../../css/commen.css">
<link rel="stylesheet" href="../../css/teacherinfo.css">
<link rel="stylesheet" href="../../css/UploadResults.css">
<body>
<div id="content">
    <div class="initer">
            <!-- 具体内容 -->
            <div class="bread">
                <div class="plain">
                    我的信息
                </div>
                <div class="plain">
                    <i class="iconfont icon-right"></i>
                </div>
                <div class="plain current">
                    个人信息
                </div>
                <div class="center-button" id="savemessage">保存信息</div>
            </div>
            <div class="teacherinfo">
                <div class="infotop">
                    <div class="img">
                        <img th:src="${person.imgface}" alt="">
                        <div class="center-button">上传照片
                            <input type="file" class="file" id="file" name="file">
                        </div>
                    </div>
                    <div class="infotable">
                        <div class="tr">
                            <div class="td">
                                <i class="iconfont icon-user"></i>
                                <span>姓名</span>
                            </div>
                            <div class="td" th:text="${person.realname}">张国庆</div>
                        </div>
                        <div class="tr">
                            <div class="td">
                                <i class="iconfont icon-shu" style="font-size:15px"></i>
                                <span>课程</span>
                            </div>
                            <div class="td" th:text="${menuStr}">第一单元：成立公司</div>
                        </div>
                    </div>
                </div>
                <div class="myinfo">
                    <div class="jianjie">
                        <i class="iconfont icon-jianjie"></i>
                        简介
                    </div>
<!--                    <div class="infodetail" th:text="${person.profile}">详细简介</div>-->
                    <textarea name="profile" id="profile" class="infodetail" style="color:#000;width: 100%;display: block;" placeholder="详细简介" th:text="${person.profile}"></textarea>
                </div>
            </div>

        </div>
</div>
<script src="../../js/jquery-3.4.1.min.js"></script>
<script src="../../js/commen.js"></script>
<script>
    $(function(){
        $("#savemessage").click(function () {
            var profile = $("#profile").val();
            $.ajax({
                type : "POST",
                url : "updateProfile",
                data : {profile: profile},
                dataType : "json",
                success : function(json) {
                    alert(json.result);
                    if(json.state == success){
                        location.reload();
                    }
                },
                error:function(msg){
                    alert("程序出错，请联系管理员");
                }
            });
        });

        $("#file").change(function () {
            if($(this).val() != ""){
                var formData = new FormData();
                formData.append("file", document.getElementById("file").files[0]);
                $.ajax({
                    url: "/file/upload",
                    type: "POST",
                    data: formData,
                    contentType: false,
                    processData: false,
                    dataType:"json",
                    success: function (data) {
                        if(data.state == success){
                            $.ajax({
                                type : "POST",
                                url : "updateHeadimg",
                                data : {imgface: data.data},
                                dataType : "json",
                                success : function(json) {
                                    alert(json.result);
                                    if(json.state == success){
                                        location.reload();
                                    }
                                },
                                error:function(msg){
                                    alert("程序出错，请联系管理员");
                                }
                            });
                        }else if(data.state == error){
                            alert(data.result);
                        }
                    },
                    error: function () {
                        alert("上传失败！");
                    }
                });
            }
        })
    });
</script>
</body>
</html>

